import axios from '@/utils/axios'

const prefix = 'base/app'

export const getApp = (id: string): Promise<ApiResult<BaseAppPO>> => {
  return axios.get(`${prefix}/${id}`)
}

export const getAppPage = (
  pagination: Pagination,
  params: BaseAppPO
): Promise<ApiResult<Page<BaseAppPO>>> => {
  return axios.get(`base/app/page/${pagination.page}/${pagination.pageSize}`, { params })
}

export const postOrPutApp = (data: BaseAppPO): Promise<ApiResult<null>> => {
  return axios.post(`base/app`, data)
}

export const deleteApp = (id: string): Promise<ApiResult<null>> => {
  return axios.delete(`base/app/${id}`)
}

export const getAppList = (): Promise<ApiResult<BaseAppPO[]>> => {
  return axios.get(`base/app/list`)
}
